package com.uzai.console.service.feign.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.uzai.console.common.UzaiRespVo;
import com.uzai.console.dto.takebal.redpacket.RedPacketQuery;
import com.uzai.console.dto.takebal.usertakebal.UserTakeBalQuery;
import com.uzai.console.dto.tb.tborder.TbOrderQuery;
import com.uzai.console.dto.user.useraccdetail.UserAccDetailQuery;
import com.uzai.console.entity.RedPacket;
import com.uzai.console.entity.TbOrder;
import com.uzai.console.entity.UserAccDetail;
import com.uzai.console.entity.UserTakeBal;
import com.uzai.console.service.feign.HistoryDataFeignService;
import com.uzai.console.service.feign.dto.HistoryTbOrderOptDto;
import com.uzai.console.vo.takebal.usertakebal.UserTakeBalReportVo;
import com.uzai.console.vo.tb.tborder.TbOrderReportVo;
import feign.hystrix.FallbackFactory;
import org.apache.commons.compress.utils.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;
import java.util.List;

/**
 * The type History data feign fallback factory.
 *
 * @author mingyang.chen create in 2022/10/28 16:15
 */
@Component
public class HistoryDataFeignFallbackFactory implements FallbackFactory<HistoryDataFeignService> {

    private static Logger logger = LoggerFactory.getLogger(HistoryDataFeignFallbackFactory.class);

    /**
     * Create history data feign service.
     *
     * @param throwable the throwable
     * @return the history data feign service
     */
    @Override
    public HistoryDataFeignService create(Throwable throwable) {

        logger.error("历史数据微服务调用出错", throwable);

        return new HistoryDataFeignService() {


            @Override
            public UzaiRespVo<List<TbOrder>> searchTbHistoryOrder(String tableSuffix, TbOrderQuery param) {
                return UzaiRespVo.success(Lists.newArrayList());
            }

            @Override
            public UzaiRespVo<Page<TbOrder>> pageTbHistoryOrder(String tableSuffix, TbOrderQuery param) {
                return UzaiRespVo.success(new Page<>());
            }

            @Override
            public UzaiRespVo<TbOrder> getTbOrder(String tableSuffix, Long id, Long merId) {
                return UzaiRespVo.success(null);
            }

            @Override
            public UzaiRespVo<TbOrderReportVo> getTbOrderStatistics(@RequestParam("tableSuffix") String tableSuffix, @RequestBody TbOrderQuery param) {
                return UzaiRespVo.success(null);
            }

            @Override
            public UzaiRespVo<Boolean> cleanOrderStatus(Long merId, Long userId, Integer filterStatus, Integer setStatus) {
                return UzaiRespVo.success(true);
            }

            @Override
            public UzaiRespVo<?> editStatusBatch(Long merId, Long userId, List<Integer> filterStatus, Integer setStatus) {
                return UzaiRespVo.fail("批量修改状态失败");
            }

            @Override
            public UzaiRespVo<Boolean> edit(String tableSuffix, HistoryTbOrderOptDto param) {
                return UzaiRespVo.fail("修改历史订单状态失败");
            }

            @Override
            public UzaiRespVo<Boolean> deleteByParam(String tableSuffix, HistoryTbOrderOptDto param) {
                return UzaiRespVo.fail("删除历史订单失败");
            }

            @Override
            public UzaiRespVo<List<UserTakeBal>> searchTakeBalHistory(String tableSuffix, UserTakeBalQuery userTakeBalQuery) {
                return UzaiRespVo.success(Lists.newArrayList());
            }

            @Override
            public UzaiRespVo<Page<UserTakeBal>> pageTakeBalHistory(String tableSuffix, UserTakeBalQuery userTakeBalQuery) {
                return UzaiRespVo.success(new Page<>());
            }

            @Override
            public UzaiRespVo<Boolean> edit(String tableSuffix, UserTakeBal userTakeBal) {
                return UzaiRespVo.fail("修改历史提现失败");
            }

            @Override
            public UzaiRespVo<UserTakeBal> getTakeBal(String tableSuffix, Long id, Long merId) {
                return UzaiRespVo.success(null);
            }

            @Override
            public UzaiRespVo<UserTakeBalReportVo> searchTakeBalStatistics(String tableSuffix, UserTakeBalQuery userTakeBalQuery) {
                return UzaiRespVo.success(null);
            }

            @Override
            public UzaiRespVo<List<RedPacket>> searchRedPacketHistory(String tableSuffix, RedPacketQuery redPacketQuery) {
                return UzaiRespVo.success(Lists.newArrayList());
            }

            @Override
            public UzaiRespVo<Page<RedPacket>> pageRedPacketHistory(String tableSuffix, RedPacketQuery redPacketQuery) {
                return UzaiRespVo.success(new Page<>());
            }

            @Override
            public UzaiRespVo<RedPacket> getRedPacket(String tableSuffix, Long id, Long merId) {
                return UzaiRespVo.success(null);
            }

            @Override
            public UzaiRespVo<BigDecimal> searchRedPacketTotalCount(@RequestParam("tableSuffix") String tableSuffix, @RequestBody RedPacketQuery redPacketQuery) {
                return UzaiRespVo.success(null);
            }

            @Override
            public UzaiRespVo<Page<UserAccDetail>> searchAccDetail(String tableSuffix, UserAccDetailQuery param) {
                return UzaiRespVo.success(new Page());
            }
        };
    }
}